package com.book.bookmanager.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ApiModel(
        value = "Menu对象",
        description = "菜单"
)
@TableName("menu")
@Data
public class Menu {
    @ApiModelProperty("菜单id")
    @TableField("menu_id")
    private Integer menu_id;

    @ApiModelProperty("component")
    @TableField("component")
    private String component;

    @ApiModelProperty("path")
    @TableField("path")
    private String path;

    @ApiModelProperty("redirect")
    @TableField("redirect")
    private String redirect;

    @ApiModelProperty("name")
    @TableField("name")
    private String name;

    @ApiModelProperty("title")
    @TableField("title")
    private String title;

    @ApiModelProperty("icon")
    @TableField("icon")
    private String icon;

    @ApiModelProperty("parentId")
    @TableField("parent_id")
    private Integer parent_id;

    @ApiModelProperty("isLeaf")
    @TableField("is_leaf")
    private String is_leaf;

    @ApiModelProperty("hidden")
    @TableField("hidden")
    private Integer hidden;

    @TableField(exist = false)
    private List<Menu> children;

    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String,Object> meta;

    public Map<String,Object> getMeta(){
        meta = new HashMap<>();
        meta.put("title",title);
        meta.put("icon",icon);
        return meta;
    }

}
